(function(window) {
    class ScoreTab {
        constructor(width, height, x, y, bgc) {
            this.width = width;
            this.height = height;
            this.x = x;
            this.y = y;
            this.bgColor = bgc;
            this.rendered = null;
        }
        render = function(father) {
            this.father = father || document.body;
            let newDiv = document.createElement('div');
            newDiv.className = 'scoreTab';
            newDiv.style.position = 'absolute';
            newDiv.style.left = `${this.x}rem`;
            newDiv.style.top = `${this.y}rem`;
            newDiv.style.width = `${this.width + 0.2}rem`;
            newDiv.style.height = `${this.height + 0.2}rem`;
            newDiv.style.background = this.bgColor;
            newDiv.style.border = `0.1rem solid #aaa`;
            newDiv.style.fontSize = '1rem';
            newDiv.innerHTML = `<h5>等级: 0</h5><h5>积分：0</h5>`
            this.rendered = newDiv;
            this.father.appendChild(newDiv);
        }
        remove = function() {
            if (this.rendered) {
                this.father.removeChild(this.rendered);
                this.rendered = null;
            }
        }
        mody = function(score, rank) {
            let tabs = document.querySelector('.scoreTab').querySelectorAll('h5');
            console.log(rank, score);
            tabs[0].innerHTML = `等级：${rank}`;
            tabs[1].innerHTML = `积分：${score}`;
        }
    }
    window.ScoreTab = ScoreTab;
}(window))